package com.dineroquegastar.urule.exception;

import com.dineroquegastar.urule.constant.RespEnum;
import lombok.Getter;

/**
 * @ClassName：BusinessException
 * @Description: 业务异常定义
 * @author： liuhai
 * @date： 2021/03/28
 */
public class BusinessException extends RuntimeException {

    @Getter
    private RespEnum respEnum;

    private String msg;

    @Getter
    private String code;

    public BusinessException(RespEnum respEnum) {
        this(respEnum.getCode(), respEnum.getMsg());
        this.respEnum = respEnum;

    }

    public BusinessException(RespEnum respEnum, String msg) {
        this(respEnum.getCode(), msg);
        this.respEnum = respEnum;
    }

    public BusinessException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String getMessage() {
        return msg;
    }
}
